package com.ait.edu.controller.front;


import com.ait.commonutils.Msg;
import com.ait.edu.entity.Course;
import com.ait.edu.entity.chapter.ChapterVo;
import com.ait.edu.entity.vo.CourseFrontVo;
import com.ait.edu.entity.vo.CourseWebVo;
import com.ait.edu.service.ChapterService;
import com.ait.edu.service.CourseService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/eduservice/CourseFront")
public class CourseFrontConttroller {

    @Autowired
    private CourseService courseService;

    @Autowired
    private ChapterService chapterService;

    @ApiOperation("分页查询")
    @PostMapping("pageCourse")
    public Msg getpageCourse(Integer currnet, Integer limit, @RequestBody(required = false) CourseFrontVo courseFrontVo){
        Page<Course> page = new Page<>(currnet,limit);
       Map<String,Object> map = courseService.getpageCourselist(page,courseFrontVo);
        return Msg.success().data(map);
    }


    @ApiOperation("课程详情")
    @GetMapping("getFrontCourseInfo")
    public Msg getFrontCourseInfo(String id){
        CourseWebVo courseWebVo = courseService.getBaseCourseInfo(id);

        List<ChapterVo> chapterVideoByCourseId = chapterService.getChapterVideoByCourseId(id);
        return Msg.success().data("courseWebVo",courseWebVo).data("chapterVideoByCourseId",chapterVideoByCourseId);
    }



}
